<html>
<head><meta charset="utf-8"><title>Byte order types · project-safe-transmute · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/index.html">project-safe-transmute</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html">Byte order types</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="211425496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425496">(Sep 27 2020 at 17:17)</a>:</h4>
<p>I would like to use transmute to vivify a file data structure, but even after setting repr(C) and avoiding padding, one issue that prevents the approach from working portably is byte order. I currently use the <code>byteorder</code> crate to make deserialization easy, but a more declarative way to do the same thing would be to have a type like <code>BigEndian&lt;u32&gt;</code> which prevents the possibility of misinterpreting the data as native endian and provides explicit conversion routines to the usual types.</p>
<p>In related work I can only find the <a href="https://docs.rs/endian-types/0.0.0/endian_types/"><code>endian_types</code></a> crate which seems to have very little traction in the community. Are there any thoughts on such an interface?</p>



<a name="211425732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425732">(Sep 27 2020 at 17:22)</a>:</h4>
<p>I would love to have endian wrappers for types, and aliases like <code>be32</code> and <code>le16</code> for the common types.</p>



<a name="211425748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425748">(Sep 27 2020 at 17:23)</a>:</h4>
<p>And, ideally, Into/From impls.</p>



<a name="211425803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425803">(Sep 27 2020 at 17:24)</a>:</h4>
<p>Part of the issue would be how to handle such types within a larger data structure.</p>



<a name="211425838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425838">(Sep 27 2020 at 17:25)</a>:</h4>
<p>Should it be <code>BE&lt;SomeStruct&gt;</code> or <code>SomeStruct&lt;BE&gt;</code>?</p>



<a name="211425853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425853">(Sep 27 2020 at 17:25)</a>:</h4>
<p>In the former case, how do you make sure the fields get swapped properly?</p>



<a name="211425854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425854">(Sep 27 2020 at 17:25)</a>:</h4>
<p>I think parameterizing all types on BE sounds like a bad idea</p>



<a name="211425860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425860">(Sep 27 2020 at 17:26)</a>:</h4>
<p>In the latter case, you have to do manual work on every type. Yes, exactly.</p>



<a name="211425899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425899">(Sep 27 2020 at 17:26)</a>:</h4>
<p>and also it might not make sense to have "the same" type over different endiannesses</p>



<a name="211425916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425916">(Sep 27 2020 at 17:26)</a>:</h4>
<p>i think <code>BigEndian&lt;u32&gt;</code> is the better answer here, and you can get "read" and "write" methods like it's a weird cell, and they'll convert as necessary automatically.</p>



<a name="211425918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425918">(Sep 27 2020 at 17:26)</a>:</h4>
<p>the endian_types crate actually uses <code>Endian&lt;u32, BE&gt;</code>, so <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="211425936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425936">(Sep 27 2020 at 17:27)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> Then how do you handle <code>BE&lt;SomeStruct&gt;</code>?</p>



<a name="211425965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425965">(Sep 27 2020 at 17:28)</a>:</h4>
<p>Personally I would rather impose the BE condition at the leaves</p>



<a name="211425989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211425989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211425989">(Sep 27 2020 at 17:28)</a>:</h4>
<p>The endianness needs to get propagated to the fields.</p>



<a name="211426000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426000">(Sep 27 2020 at 17:28)</a>:</h4>
<p>i.e. your struct consists of <code>be32</code> and <code>be64</code> fields</p>



<a name="211426003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426003">(Sep 27 2020 at 17:28)</a>:</h4>
<p>I've never had a use case where that's come up so I don't quite understand the motivation. When working with, say, a PNG header, it's quite sufficient to say that a given field in the header is <code>BE&lt;u32&gt;</code> and not that the entire struct is. I think that BE/LE should <em>only</em> be used around primitive number values.</p>



<a name="211426088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426088">(Sep 27 2020 at 17:30)</a>:</h4>
<p>I can imagine it might be convenient to just say it once at the top level but it also sounds a little magic and could be a footgun</p>



<a name="211426092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426092">(Sep 27 2020 at 17:30)</a>:</h4>
<p>so probably you should do that with a macro</p>



<a name="211426183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426183">(Sep 27 2020 at 17:32)</a>:</h4>
<p>something like <code>Endian&lt;u32, BE&gt;</code> sounds almost like what i'd want to use anyway, just that i'd be willing to accept twice as many types if it means half as many generics i write down.</p>



<a name="211426213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426213">(Sep 27 2020 at 17:34)</a>:</h4>
<p>I think it's mostly just an easy way to fill out the matrix though; I don't see a reason to have any more than <code>[le/be][16/32/64]</code></p>



<a name="211426254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426254">(Sep 27 2020 at 17:34)</a>:</h4>
<p>possibly floats too but I don't know the rules around that</p>



<a name="211426267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426267">(Sep 27 2020 at 17:35)</a>:</h4>
<p>i think the story there is "big-endian floats exist, but most big-endian systems are only big-endian for integers, not for floats, and you've got something extra weird when there's big-endian floats too"</p>



<a name="211426317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426317">(Sep 27 2020 at 17:36)</a>:</h4>
<p>wait, so the 25 or so bits of mantissa are laid out in adjacent bytes in a little endian way even on big endian machines?</p>



<a name="211426322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426322">(Sep 27 2020 at 17:36)</a>:</h4>
<p>that's so weird</p>



<a name="211426336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426336">(Sep 27 2020 at 17:36)</a>:</h4>
<p>that's what i was told, but i could have heard wrong</p>



<a name="211426350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426350">(Sep 27 2020 at 17:37)</a>:</h4>
<p>wikipedia claims the reverse (also?) exists: little endian integers, big endian floats</p>



<a name="211426402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426402">(Sep 27 2020 at 17:38)</a>:</h4>
<p>and ARM apparently does 64 bit floats in big endian 32 bit chunks but the chunks are little endian</p>



<a name="211426421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426421">(Sep 27 2020 at 17:39)</a>:</h4>
<p>anyway, so 3 widths, times 2 signednesses, times 2 endiannesses, not bad, could throw it together easily</p>



<a name="211426472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211426472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211426472">(Sep 27 2020 at 17:41)</a>:</h4>
<p>I guess ideally that could get into <code>core</code> some day.</p>



<a name="211430759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211430759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211430759">(Sep 27 2020 at 19:32)</a>:</h4>
<p>The main reason I'd be interested in having <code>BE&lt;MyStruct&gt;</code> is that there are some structures which commonly appear in both some-specific-endian and host-endian form, and it'd be helpful to be able to translate the whole structure once (ideally in-place) and then use it. And rather than having a special <code>MyStructBE</code>, I'd like to have a common name for it, and common methods for it.</p>



<a name="211430841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211430841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211430841">(Sep 27 2020 at 19:34)</a>:</h4>
<p>Ah, I've only had to worry about non-native-endian values with file formats</p>



<a name="211432119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211432119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211432119">(Sep 27 2020 at 20:02)</a>:</h4>
<p>File formats, network formats, and hardware formats are the most common cases where I run into them.</p>



<a name="211432128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211432128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211432128">(Sep 27 2020 at 20:03)</a>:</h4>
<p>In many cases, I'd like to translate them to native-endian as soon as I get them.</p>



<a name="211432913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211432913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211432913">(Sep 27 2020 at 20:23)</a>:</h4>
<p>If the underlying type is <code>Endian&lt;integer, LE/BE&gt;</code> then you could parameterize your struct on the <code>LE/BE</code> marker if you need to for this kind of thing</p>



<a name="211432969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211432969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211432969">(Sep 27 2020 at 20:24)</a>:</h4>
<p>although it would be slightly inconvenient that <code>Endian&lt;u32, NE&gt; != u32</code> assuming another marker for native endianness</p>



<a name="211432972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211432972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211432972">(Sep 27 2020 at 20:24)</a>:</h4>
<p>I guess you could use an associated type to make that work?</p>



<a name="211496576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211496576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211496576">(Sep 28 2020 at 14:05)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span>, check out the <a href="https://docs.rs/zerocopy/0.3.0/zerocopy/byteorder/index.html">byteorder module of zerocopy</a>! It's the bedrock of Fuchsia's rust-based networking stack.</p>



<a name="211496851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211496851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211496851">(Sep 28 2020 at 14:07)</a>:</h4>
<p>IMO, that module is such an obvious addition to the <code>byteorder</code> crate that it should up be upstreamed there.</p>



<a name="211496934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Byte%20order%20types/near/211496934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Byte.20order.20types.html#211496934">(Sep 28 2020 at 14:08)</a>:</h4>
<p>I suspect <span class="user-mention" data-user-id="132362">@Joshua Liebow-Feeser</span> might have something to say about all this, though!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>